<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>$nextTick</title>
    <script src="js/vue.js"></script>
</head>
<body>
    <div id="app">
        <span id="span" v-if="showSpan"> this is a span</span>
        <button @click="getSpanText">获取span值</button>
    </div>
</body>
<script>
    new Vue({
        el: '#app',
        data: {
            showSpan: false
        },
        methods: {
            getSpanText: function () {
                this.showSpan = true;
                /**
                 * 获取不到span
                 * @type {string}
                 */
                let span = document.getElementById('span');
                this.$nextTick(function () {
                    let text = document.getElementById('span').innerHTML;
                    console.log(text);
                    this.showSpan = false;
                })

            }
        }
    })
</script>
</html>